<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 引入在线的leaflet依赖 -->
    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
        integrity="sha256-kLaT2GOSpHechhsozzB+flnD+zUyjE2LlfWPgU04xyI=" crossorigin="" />
    <script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"
        integrity="sha256-WBkoXOwTeyKclOHuWtc+i2uENFpDZ9YPdf5Hf+D7ewM=" crossorigin=""></script>
    <!-- js依赖 -->
    <!-- <script src="https://lib.baomitu.com/leaflet/1.9.2/leaflet.js"></script> -->
    <!-- css依赖 -->
    <!-- <link rel="stylesheet" href="https://lib.baomitu.com/leaflet/1.9.2/leaflet.css"> -->
    <!-- 沿着坐标路径绘制图案 -->
    <script
        src="https://cdn.jsdelivr.net/npm/leaflet-polylinedecorator@1.6.0/dist/leaflet.polylineDecorator.min.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0
        }

        #map {
            height: 100vh;
        }
    </style>
</head>

<body>
    <div id="map"></div>
    <script>
        var url = 'https://api.mapbox.com/styles/v1/mapbox/streets-v11/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoiY2hlbmdiZW5jaGFvIiwiYSI6ImNsODU3aGRiODA0Y2UzcHBzZmFlcmdqZ2sifQ.8k59W_pB_Riwe6o-MneRlA'
        var layer = L.tileLayer(url, {
            maxZoom: 19,
            attribution: '© OpenStreetMap'
        })
        const map = L.map("map", {
            center: [0, 0],
            zoom: 1,
            layers: [layer]
        })
        //绘制图层
        var drawnItems = new L.FeatureGroup();
        //添加绘制图层
        map.addLayer(drawnItems);
        /* 1.--------------------------------------------- */
        //绘制连线矩形
        var polygon = L.polygon([[0, -90], [10, -90], [10, -70], [0, -70], [0, -90], [20, -90], [30, -90], [30, -70], [20, -70], [20, -90]], {
            //线颜色
            color: "#ff7800",
            //线宽
            weight: 1
        }).addTo(drawnItems);
        // 装饰这个连线矩形
        var pd = L.polylineDecorator(polygon, {
            //添加模式
            patterns: [{
                //模式符号的偏移位置
                offset: 0,
                //模式符号的重复间隔
                repeat: 10,
                //符号实例
                symbol: L.Symbol.dash({
                    //符号大小
                    pixelSize: 0
                })
            }]
        }).addTo(drawnItems);

        /* 2.----------------------------------------- */
        //绘制虚线矩形
        var pathPattern = L.polylineDecorator([[0, -60], [10, -60], [10, -40], [0, -40], [0, -60]], {
            //添加模式
            patterns: [{
                //模式符号的偏移位置
                offset: 12,
                //模式符号的重复间隔
                repeat: 25,
                //符号实例
                symbol: L.Symbol.dash({
                    //符号大小
                    pixelSize: 10,
                    //符号样式
                    pathOptions: {
                        //颜色
                        color: '#f00',
                        //线宽
                        weight: 2
                    }
                })
            },
            {
                //模式符号的偏移位置
                offset: 0,
                //模式符号的重复间隔
                repeat: 25,
                //符号实例
                symbol: L.Symbol.dash({
                    //符号大小
                    pixelSize: 10
                })
            }
            ]
        }).addTo(drawnItems);
        /* 3.------------------------------------- */
        //添加线
        var markerLine = L.polyline([[-10, -70], [0, -55], [-20, -45], [0, -75]], {}).addTo(drawnItems);
        //在线上添加标注
        var markerPatterns = L.polylineDecorator(markerLine, {
            //添加模式
            patterns: [{
                //模式符号的偏移位置
                offset: '5%',
                //模式符号的重复间隔
                repeat: '10%',
                //符号实例
                symbol: L.Symbol.marker({
                })
            }]
        }).addTo(drawnItems);
        // 4.----------------------------------------
        //矩形框上添加图片
        var pathPattern = L.polylineDecorator([[-20, -90], [-10, -90], [0, -80], [-10, -70], [-20, -70], [-20, -90]], {
            //添加模式
            patterns: [
                {
                    //模式符号的偏移位置
                    offset: 0,
                    //模式符号的重复间隔
                    repeat: 10,
                    //符号实例
                    symbol: L.Symbol.dash({
                        //符号大小
                        pixelSize: 5,
                        //符号样式
                        pathOptions: {
                            //颜色
                            color: '#000',
                            //线宽
                            weight: 1,
                            //透明度
                            opacity: 0.2
                        }
                    })
                },
                {
                    //模式符号的偏移位置
                    offset: '0%',
                    //模式符号的重复间隔
                    repeat: '20%',
                    //符号实例
                    symbol: L.Symbol.marker({
                        //是否允许旋转
                        rotate: true,
                        //标记显示样式
                        markerOptions: {
                            //图标
                            icon: L.icon({
                                //图标地址
                                iconUrl: '../../libs/leaflet/plugins/Leaflet.PolylineDecorator-master/example/icon_plane.png',
                                //图标位置
                                iconAnchor: [16, 16]
                            })
                        }
                    })
                }
            ]
        }).addTo(drawnItems);
        /* 5.-------------------------------------------------------- */
        //线要素点集
            var multiCoords1 = [
                [[-27.5468, -70.7910], [-28.8068, -70.1318], [-29.1242, -69.6699], [-29.4966, -67.2958], [-11.4266, -68.8564], [-11.7542, -68.1093]],
                [[-28.0193, -72.8125], [-26.3165, -72.8564], [-24.9336, -71.0107], [-24.5278, -69.5820], [-24.8714, -67.7353], [-25.8287, -65.1855], [-28.1953, -65.1416]],
                [[-25.9205, -70.4394], [-26.7699, -70.9228], [-27.6061, -68.5488], [-27.7540, -67.3837]]
            ];
            var plArray = [];
    </script>
</body>

</html>